<template>
  <div>
    <a-card title="资源列表">
      <div class="table-page-search-wrapper">
        <a-form-model
          layout="inline"
          :model="queryParam"
        >
          <a-row :gutter="15">
            <a-col :md="6" :sm="24">
              <a-form-model-item label="联系电话">
                <a-input v-model="queryParam['filter[phone]']"/>
              </a-form-model-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="业务名称">
                <a-input v-model="queryParam['filter[b_name]']"/>
              </a-form-model-item>
            </a-col>
            <template v-if="advanced">
              <a-col :md="6" :sm="24">
                <a-form-item label="入库时间">
                  <a-range-picker @change="onTime1" />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="领取时间">
                  <a-range-picker @change="onTime2" />
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="业务分类">
                  <a-select v-model="queryParam['filter[first_type]']" :default-value="0">
                    <a-select-option v-for="(item,index) in firstTypeOpts" :key="index" :value="index">
                      {{item}}
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="搜索引擎">
                  <a-input v-model="queryParam['filter[search_engine]']"/>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="首次页面">
                  <a-input v-model="queryParam['filter[first_url]']"/>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="领取状态">
                  <a-select v-model="queryParam['filter[receive_status]']" :default-value="0">
                    <a-select-option v-for="(item,index) in receiveStatusOpts" :key="index" :value="index">
                      {{item}}
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="按搜索词">
                  <a-input v-model="queryParam['filter[search_keywords]']"/>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="领取顾问">
                  <a-input v-model="queryParam['filter[receiver_info]']"/>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="搜索的IP">
                  <a-input v-model="queryParam['filter[ip]']"/>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="放弃状态">
                  <a-select v-model="queryParam['filter[is_abandon]']" :default-value="0">
                    <a-select-option v-for="(item,index) in abandonStatusOpts" :key="index" :value="index">
                      {{item}}
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-model-item label="客户状态">
                  <a-select v-model="queryParam['filter[customer_status]']" :default-value="0">
                    <a-select-option v-for="(item,index) in customerStatusOpts" :key="index" :value="index">
                      {{item}}
                    </a-select-option>
                  </a-select>
                </a-form-model-item>
              </a-col>
            </template>
            <a-col :md="!advanced && 8 || 24" :sm="24">
                <span class='table-page-search-submitButtons' :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
                  <a-button type="primary" @click="$refs.table.refresh(true)">搜索</a-button>
                  <a-button style="margin-left: 8px" @click="resetForm">重置</a-button>
                  <a @click="toggleAdvanced" style="margin-left: 8px">
                    {{ advanced ? '收起' : '展开' }}
                    <a-icon :type="advanced ? 'up' : 'down'" />
                  </a>
                </span>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
      <s-table
        bordered
        ref="table"
        :row-key="(record) => record.customer_id"
        :columns="customerColumns"
        :data="customerData"
      >
        <template slot='ip' slot-scope='text,record'>
          {{record.device}}<br>{{text}}<br>{{record.ip_format}}
        </template>
        <template slot="search_keywords" slot-scope="text,record">
          <div>{{text}}</div>
          <div>{{record.search_engine}}</div>
        </template>
        <template slot='first_url' slot-scope='text'>
          <a :href='text' target='_blank'>{{text}}</a>
        </template>
        <template slot='action' slot-scope='text,record'>
          <a-button type='primary' size='small' style="margin-right:5px" :disabled="record.transfer == 0" @click="onTransfer(record.customer_id)">转移</a-button>
          <a-button type='danger' size='small' @click="onDelete(record.customer_id)">删除</a-button>
        </template>
      </s-table>
    </a-card>
  </div>
</template>

<script>
  import { STable } from '@/components'
  import col from '@/columns/customer'
  export default {
    components: {
      STable
    },
    name: 'AllCustomer',
    data () {
      return {
        queryParam: {},
        customerColumns: col.all_list2,
        customerData: () => {
          return new Promise(resolve => {
            resolve({
              data: []
            })
          })
        }
      }
    }
  }
</script>

<style scoped>

</style>
